package com.hlw.springboot.mapper;

import com.hlw.springboot.entity.SysRole;
import com.hlw.springboot.entity.SysUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface SysRoleMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(SysRole record);

    int insertSelective(SysRole record);

    SysRole selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(SysRole record);

    int updateByPrimaryKey(SysRole record);

    @Select(" select rid from sys_user_role where uid = #{uid}")
    Integer findRoleByUid(@Param("uid")Integer uid);

    @Select("select * from sys_role r inner join sys_user_role ru on r.id = ru.rid where ru.uid = #{userId}")
    List<SysRole> listByUserId(int userId);


    //layui前台可根据条件进行查询
    List<SysRole> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);

    int count(@Param("params") Map<String, Object> params);

    @Select("select count(*) from sys_role where name = #{name}")
    int checktByName(String name);

    @Select("select * from sys_role")
    List<SysRole> findAll();



}